{extend name="extend:iframe" /} {block name="css"}
<style type="text/css">
	._1 img {
		float: left;
		width: 40px;
		height: 40px;
		border-radius: 30px;
	}

	._1 div {
		float: left;
		margin-left: 5px;
	}

	._1 div p {
		font-size: 12px;
		height: 20px;
		line-height: 20px;
	}

	._2 p {
		font-size: 12px;
		height: 20px;
		line-height: 20px;
	}

	font {
		color: #999;
		font-size: 14px;
	}

	.text-center {
		text-align: center;
	}

	.cmd-box {
		line-height: 40px;
		position: relative;
	}

	.select-box {
		display: none;
		width: 100%;
		box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.08);
		padding: 0;
		margin: 0;
		list-style: none;
		background-color: #FFFFFF;
		position: absolute;
		top: 40px;
		left: 0;
	}

	.cmd-box:hover .select-box {
		display: block;
		z-index: 9;
	}

	.select-box li {
		line-height: 32px;
		border-bottom: 1px solid #EDEDED;
	}

	.select-box li:hover {
		background-color: #FCFCFC;
	}

	.select-box li a {
		font-size: 14px;
	}
	.v-valign {
	    display: -webkit-box!important;
	    display: -webkit-flex!important;
	    display: -ms-flexbox!important;
	    display: flex!important;
	    -webkit-box-align: center!important;
	    -webkit-align-items: center!important;
	    -ms-flex-align: center!important;
	    align-items: center!important;
	}
	.m-x-auto {
	    margin-left: auto!important;
	    margin-right: auto!important;
	}
</style>
{/block} {block name="body"}
<div class="_title">
	<div class="_main">会员管理</div>
	<div class="_sub clearfix">
		<div class="_btns">
			<ul class="clearfix">
				<li class="active" layout-mark="list-model" data-model="0">全部</li>
				<li layout-mark="list-model" data-model="1">待审核</li>
				<li layout-mark="list-model" data-model="2">已锁定</li>
			</ul>
		</div>
		<div class="_search clearfix">
			<select layout-mark="list-role">
				<option selected value="0">全部</option>
				<option value="1">创业者</option>
				<option value="2">投资者</option>
			</select>
			<input type="text" name="skey" placeholder="手机号" />
			<a href="javascript:;" layout-mark="list-skey"><i class="icon-search_-for"></i></a>
		</div>
	</div>
</div>
<div class="_content">
	<table width="100%">
		<tr>
			<th>会员</th>
			<th>角色</th>
			<th>手机</th>
			<th>微信</th>
			<th>邮箱</th>
			<th>钱包</th>
			<th>名片</th>
			<th>状态</th>
			<th class="text-center">操作</th>
		</tr>
		<tbody id="member-volist-view">

		</tbody>
	</table>
</div>
<div class="loadmore-modal">
	<a href="javascript:;">点击加载更多</a>
</div>
{/block} {block name="js"}
<script type="text/html" id="member-volist-template">
	{{# for ( var i in d ) { }}
		{{# var list = d[i]; }}
		{{# if (!list.info) { continue; } }}
		<tr>
			<td>
				<div class="_1 clearfix">
					<img src="{{ list.info.headimgurl }}" />
					<div class="">
						<p>{{ list.info.nickname }}</p>
						<p>
							{{ list.info.province == '' ? '
							<font>未知</font>' : list.info.province }} {{ list.info.city == '' ? '
							<font>未知</font>' : list.info.city }}
						</p>
					</div>
				</div>
			</td>
			<td>
				{{# if ( list.role == 3 ) { }}
				<div class="_2">
					<p>{{ formatRole(list.role) }}</p>
					<p>{{ list.organization }}</p>
				</div>
				{{# } else { }} {{ formatRole(list.role) }} {{# } }}
			</td>
			<td>{{ list.mobile }}</td>
			<td>{{ list.info.wechat == '' ? '
				<font>未设置</font>' : list.info.wechat }}</td>
			<td>{{ list.info.email == '' ? '
				<font>未设置</font>' : list.info.email }}</td>
			<td style="color:#C91723">{{ list.account }}</td>
			<td style="color:#C91723">
				{{# if ( list.card && list.card != '' ) { }}
					<i class="icon-menu_um" layout-mark="card-render" data-uri="{{ list.card }}" style="color:#FF5300;cursor: pointer;"></i>
				{{# } else { }}
					<i class="icon-menu_um"></i>
				{{# } }}
			</td>
			<td>{{ formatStatus(list.status) }}</td>
			<td class="text-center cmd-box">
				<i class="icon-down" style="cursor: pointer;"></i>
				<ul class="select-box">
					{{# if ( list.status == 9 ) { }}
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="sh" data-id="{{ list.id }}" data-status="0">通过</a>
					</li>
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="jj" data-id="{{ list.id }}" data-status="1">拒绝</a>
					</li>
					{{# } else if ( list.status == 1 ) { }}
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="js" data-id="{{ list.id }}" data-status="0">解锁</a>
					</li>
					{{# } else if ( list.status == 0 ) { }}
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="sd" data-id="{{ list.id }}" data-status="1">锁定</a>
					</li>
					{{# } }}
				</ul>
			</td>
		</tr>
	{{# } }}
</script>
<script type="text/javascript" src="/public/plug/layer/layer.min.js"></script>
<script type="text/javascript" src="/public/plug/laytpl/laytpl.min.js"></script>
<script type="text/javascript" src="/public/modules/tool.js"></script>
<script type="text/javascript" src="/public/modules/interactive.js"></script>
<script type="text/javascript">
	$(function() {
		// 操作
		$('#member-volist-view').on('click', 'a[data-cmd]', function() {
			var that = $(this),
				data_opt = {
					'member_id': that.attr('data-id'),
					'status': that.attr('data-status')
				};
			layer.load(0, {
				shade: [0.08, '#000']
			});
			ajax().put('/api?member.admin.audit', data_opt, function(res) {
				layer.closeAll('loading');
				if(res.status == 201) {
					window.parent.system.success('操作成功', function() {
						window.location.reload();
					});
				} else {
					window.parent.system.error(res.error);
				}
			});
		}).on('click', '[layout-mark=card-render]', function() {
			var uri = $(this).attr('data-uri');
			layer.open({
				type: 1,
				title: false,
				area: ['320px', '320px'],
				shadeClose: true,
				content: '<div class="v-valign" style="width: 320px; height: 320px"><img style="display: block;" class="m-x-auto" src="' + uri + '" /></div>'
			});
		});

		// 模式
		$('li[layout-mark=list-model]').on('click', function(e) {
			$('#member-volist-view').html('');
			data_opt_volist['model'] = $(this).attr('data-model');
			data_opt_volist['page'] = 1;
			getIndexVolist();
		});

		// 角色
		$('select[layout-mark=list-role]').on('change', function(e) {
			$('#member-volist-view').html('');
			data_opt_volist['role'] = $(this).val();
			data_opt_volist['page'] = 1;
			getIndexVolist();
		});

		// 搜索
		$('a[layout-mark=list-skey]').on('click', function(e) {
			var skey = $.trim($('input[name=skey]').val());
			$('#member-volist-view').html('');
			data_opt_volist['skey'] = skey;
			data_opt_volist['page'] = 1;
			getIndexVolist();
		});

		// 加载更多
		$('.loadmore-modal a').on('click', function(e) {
			var next = $(this).data('next');
			if(next > 0) {
				data_opt_volist['page'] = next;
				getIndexVolist();
			}
		});
	});

	var template = document.getElementById('member-volist-template').innerHTML,
		data_opt_volist = dataOptVolist();

	// 加载列表
	function getIndexVolist() {
		layer.load(0, {
			shade: [0.08, '#000']
		});
		ajax().get('/api?member.admin.volist', data_opt_volist, function(res) {
			layer.closeAll('loading');
			if(res.status >= 200 && res.status < 300) {
				$('.loadmore-modal a').data('next', res.data.next);
				if(res.data.list.length > 0) {
					// 渲染列表
					var tpl = laytpl(template);
					$('#member-volist-view').append(tpl.render(res.data.list));
					// 判断是否有分页
					if(res.data.next > res.data.page) {
						$('.loadmore-modal a').html('点击加载更多');
					} else {
						$('.loadmore-modal a').html('');
					}
				} else {
					$('.loadmore-modal a').html('暂无记录');
				}
			} else {
				window.parent.system.error(res.error);
			}
			resetIframeHeight();
		});
	}

	getIndexVolist();

	function formatRole(role) {
		var role = parseInt(role);
		switch(role) {
			case 0:
				return '未定义';
			case 1:
				return '创业者';
			case 2:
				return '个人天使';
			case 3:
				return '机构投资人';
			default:
				return '未定义';
		}
	}

	function formatStatus(status) {
		var status = parseInt(status);
		switch(status) {
			case 0:
				return '<font style="color:#44B549;">正常</font>';
			case 1:
				return '<font style="color:#D9534F;">锁定</font>';
			case 9:
				return '<font style="color:#F0AD4E;">待审核</font>';
			default:
				return '未知';
		}
	}

	function dataOptVolist(opts) {
		return tool.optionExtend({
			'page': 1, // 当前页数
			'show': 10, // 显示条数
			'model': 0, // 模式,0-全部(默认) 1-待审核 2-已锁定
			'role': 0, // 角色,0-全部(默认) 1-创业者 2-投资者
			'skey': '' // 搜索关键词,手机号
		}, opts || {});
	}
</script>
{/block}
